﻿<ResourceDictionary
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">

    <!-- Resource dictionary entries should be defined here. -->
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="Colors.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <Style x:Key="ListBoxItemStyle" TargetType="{x:Type ListBoxItem}">
		<Setter Property="Padding" Value="3" />
		<Setter Property="HorizontalContentAlignment" Value="Left" />
		<Setter Property="VerticalContentAlignment" Value="Top" />
		<Setter Property="Background" Value="Transparent" />
		<Setter Property="Foreground">
			<Setter.Value>
				<SolidColorBrush Color="{StaticResource Application_ListBoxItem_Foreground}"/>
			</Setter.Value>
		</Setter>
		<Setter Property="IsTabStop" Value="True" />
        <Setter Property="Template" Value="{DynamicResource {ComponentResourceKey ResourceId=ListBoxItemTemplate, TypeInTargetAssembly={x:Type ListBoxItem}}}"/>
	</Style>

    <ControlTemplate x:Key="{ComponentResourceKey ResourceId=ListBoxItemTemplate, TypeInTargetAssembly={x:Type ListBoxItem}}" TargetType="ListBoxItem">
        <Grid Background="{TemplateBinding Background}">
    		<VisualStateManager.VisualStateGroups>
    			<VisualStateGroup x:Name="CommonStates">
    				<VisualStateGroup.Transitions>
    					<VisualTransition From="Normal" GeneratedDuration="0:0:0.4" To="MouseOver"/>
    					<VisualTransition From="MouseOver" GeneratedDuration="0:0:0.4" To="Normal"/>
    				</VisualStateGroup.Transitions>
    				<VisualState x:Name="Normal"/>
    				<VisualState x:Name="MouseOver">
    					<Storyboard>
    						<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)" Storyboard.TargetName="bg">
    							<EasingColorKeyFrame KeyTime="0" Value="{StaticResource Application_ListBoxItem_Background_Move}"/>
    						</ColorAnimationUsingKeyFrames>
    					</Storyboard>
    				</VisualState>
    				<VisualState x:Name="Disabled">
    					<Storyboard>
    						<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)">
    							<EasingColorKeyFrame KeyTime="0" Value="{StaticResource Application_ListBoxItem_Foreground_Disabled}"/>
    						</ColorAnimationUsingKeyFrames>
    					</Storyboard>
    				</VisualState>
    			</VisualStateGroup>
    			<VisualStateGroup x:Name="SelectionStates">
    				<VisualStateGroup.Transitions>
    					<VisualTransition GeneratedDuration="0:0:0.2" To="Selected"/>
    					<VisualTransition From="Selected" GeneratedDuration="0:0:0.2"/>
    					<VisualTransition From="Selected" GeneratedDuration="0:0:0.3" To="SelectedUnfocused"/>
    				</VisualStateGroup.Transitions>
    				<VisualState x:Name="Unselected"/>
    				<VisualState x:Name="Selected">
    					<Storyboard>
    						<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="SelectionFill">
    							<EasingDoubleKeyFrame KeyTime="0" Value="1"/>
    						</DoubleAnimationUsingKeyFrames>
    						<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="SelectionBorder">
    							<EasingDoubleKeyFrame KeyTime="0" Value="1"/>
    						</DoubleAnimationUsingKeyFrames>
    					</Storyboard>
    				</VisualState>
    				<VisualState x:Name="SelectedUnfocused">
    					<Storyboard>
    						<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="SelectionBorder">
    							<EasingDoubleKeyFrame KeyTime="0" Value="1"/>
    						</DoubleAnimationUsingKeyFrames>
    					</Storyboard>
    				</VisualState>
    			</VisualStateGroup>
    			<VisualStateGroup x:Name="FocusStates">
    				<VisualState x:Name="Unfocused"/>
    				<VisualState x:Name="Focused"/>
    			</VisualStateGroup>
    		</VisualStateManager.VisualStateGroups>
    		<Rectangle x:Name="bg" Opacity="1" IsHitTestVisible="False" RadiusX="1" RadiusY="1">
    			<Rectangle.Fill>
    				<SolidColorBrush Color="{StaticResource Application_ListBoxItem_Background}"/>
    			</Rectangle.Fill>
    		</Rectangle>
    		<Rectangle x:Name="SelectionFill" Grid.Column="0" Grid.ColumnSpan="1" RadiusX="0" Opacity="0" Height="Auto" Margin="0" VerticalAlignment="Stretch">
    			<Rectangle.Fill>
    				<SolidColorBrush Color="{StaticResource Application_ListBoxItem_Background_Selection}" />
    			</Rectangle.Fill>
    		</Rectangle>
    		<ContentPresenter x:Name="contentPresenter" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"
    			HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalAlignment}"/>
    		<Rectangle x:Name="SelectionBorder" Grid.Column="0" Grid.ColumnSpan="1" Opacity="0" StrokeThickness="1" IsHitTestVisible="False" Height="Auto" Margin="0" VerticalAlignment="Stretch">
    			<Rectangle.Stroke>
    				<SolidColorBrush Color="{StaticResource Application_ListBoxItem_BorderBrush_Selection}" />
    			</Rectangle.Stroke>
    		</Rectangle>
    	</Grid>
    </ControlTemplate>

</ResourceDictionary>